import request from './axios'

const post = async (url, data) => {
  return new Promise((resolve, reject) => {
    request
      .post(url, data)
      .then(res => resolve(res))
      .catch(err => reject(err))
  })
}
const put = async (url, data) => {
  return new Promise((resolve, reject) => {
    request
      .put(url, data)
      .then(res => resolve(res))
      .catch(err => reject(err))
  })
}
const get = async (url, data) => {
  return new Promise((resolve, reject) => {
    request
      .get(url, { params: data })
      .then(res => resolve(res))
      .catch(err => reject(err))
  })
}
const del = async (url, data) => {
  return new Promise((resolve, reject) => {
    request
      .del(url, { params: data })
      .then(res => resolve(res))
      .catch(err => reject(err))
  })
}
export default {
  post,
  put,
  get,
  del
}
